﻿CREATE TABLE [dbo].[DBInstruments] (
    [ID]             UNIQUEIDENTIFIER DEFAULT (newid()) NOT NULL,
    [Name]           VARCHAR (255)    NOT NULL,
    [Type]           VARCHAR (32)     DEFAULT ('Unknown') NOT NULL,
    [Classe]         VARCHAR (32)     DEFAULT ('Unknown') NOT NULL,
    [Sector]         VARCHAR (32)     DEFAULT ('Unknown') NOT NULL,
    [ISIN]           CHAR (255)       DEFAULT ('FRXXXXXXXXXX') NOT NULL,
    [Country]        VARCHAR (255)    NULL,
    [Capitalization] BIGINT           DEFAULT ((0)) NOT NULL,
    [BelongToIndex]  VARCHAR (255)    DEFAULT ('Not defined') NOT NULL,
    [Refinancing]    INT              NULL,
    [Maturity]       DATETIME         NULL,
    [ExchangeID]     UNIQUEIDENTIFIER NULL,
    [CurrencyID]     UNIQUEIDENTIFIER NULL,
    PRIMARY KEY CLUSTERED ([ID] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF),
    UNIQUE NONCLUSTERED ([Name] ASC) WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF),
    FOREIGN KEY ([ExchangeID]) REFERENCES [dbo].[DBExchange] ([ID]) ON DELETE CASCADE ON UPDATE NO ACTION,
    FOREIGN KEY ([CurrencyID]) REFERENCES [dbo].[DBCurrency] ([ID]) ON DELETE NO ACTION ON UPDATE NO ACTION
);

